﻿namespace EFS.Common
{
	public static class Directory
	{
		public static System.String MapApplicationPath(System.String append)
		{
			// rooth path
			System.String root = null;

			// get entry or executing
			System.Reflection.Assembly assembly = System.Reflection.Assembly.GetEntryAssembly();
			if (null != assembly)
			{
				root = System.IO.Path.GetDirectoryName(assembly.Location);
			}
			else
			{
				assembly = System.Reflection.Assembly.GetExecutingAssembly();
				root = System.IO.Path.GetDirectoryName(assembly.CodeBase).Replace(@"file:\", "");
			}
			
			// check append
			if (EFS.Common.Verify.String(append))
			{
				// append
				return System.IO.Path.Combine(root, append);
			}

			// just root
			return root;
		}
	}
}
